package com.itheima.d8_dateAPI;

import java.util.Calendar;
import java.util.Date;

public class Test01 {
    public static void main(String[] args) {
        // 目标：掌握Calendar的使用和特点。
        // 1、得到系统此刻时间对应的日历对象。
        Calendar now = Calendar.getInstance();
        System.out.println(now);

        //2.获取日历中的某个信息
        int year = now.get(Calendar.YEAR);
        System.out.println(year);

        int days = now.get(Calendar.DAY_OF_YEAR);
        System.out.println(days);

        //3.拿到日历中记录的日期对象
        Date d = now.getTime();
        System.out.println(d);

        //4.拿到时间毫秒值
        long time = now.getTimeInMillis();
        System.out.println( time);

        //5.修改日历中的某个信息
        now.set(Calendar.YEAR, 2020);
        now.set(Calendar.MONTH, 10);
        now.set(Calendar.DAY_OF_MONTH, 10);
        System.out.println(now);

        //6.为某个信息增加或者减少多少
        now.add(Calendar.YEAR, 10);
        now.add(Calendar.YEAR, -110);
        now.add(Calendar.HOUR, 6);
        now.set(2090,1,1);
        System.out.println(now);
    }
}
